<?php
/**
 * Created by PhpStorm.
 * User: zq
 * Date: 2018/3/20
 * Time: 13:49
 */


use Illuminate\Database\Capsule\Manager as DB;

class TestTikuXx01Model extends BaseModel
{
    const TABLE    = 'rp.sh_testquestion_1000';
//    const TABLE1    = \Yaf\Application::app()->getConfig()->tiku->table;

    public function init() {

    }

    public static function get($where = [], $offset = 0, $limit = 10)
    {
        $table = \Yaf\Application::app()->getConfig()->tiku->table;
        $where_sql = " p_img_ok=0 and subjectid=10011 ";

        $sql = "select * from " . $table . " where $where_sql order by id limit $offset, $limit";
        $res = DB::connection()->select($sql);
        return $res;
    }


    public static function update($id, $data)
    {
        $table = \Yaf\Application::app()->getConfig()->tiku->table;
        DB::connection()->table($table)->where(['id' => $id,])->update($data);
    }

    public static function getAll($table, $select, $where = [], $offset = 0, $limit = 10, $order = '')
    {
        $res = DB::connection()->table($table)->where($where)->offset($offset)->limit($limit)->selectRaw($select)->orderByRaw($order)->get();
        return $res;
    }


}